<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta name = "format-detection" content = "telephone=no">
    <title>地址定位</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/address.css">
    <style type="text/css">
        html{height:500px}
        body{height:500px;margin:0px;padding:0px}
        #container{height:50%}
    </style>
    <include file="Public/common_js"/>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=0LL8ncNYcc0ql5CMYEW9zk3pH9TvvMAo"></script>
</head>   
    <div id="container"></div>
    <div class="warp">
        <div class="location-box" >
            <div class="location-result pdLR">
                <ul>
                    <li>
                        <p>贝蒙盘古<label>当前</label></p>
                        <p>重庆市两江新区新牌坊江北车管所前行200米</p>
                    </li>
                    <li>
                        <p>中渝都会首站</p>
                        <p>重庆市渝北区宝胜大道301号</p>
                    </li>
                    <li>
                        <p>阳光幼儿园</p>
                        <p>重庆市渝北区宝胜大道301号</p>
                    </li>
                </ul>
            </div>
        </div>
    </div>
     <script type="text/javascript">
		require(['addressLocation']);
        var map = new BMap.Map("container");
        map.enableScrollWheelZoom(true);
        var markerTmp,lng="106.535645",lat="29.61527";
        if(lng != '' && lat != ''){
            map.centerAndZoom(new BMap.Point(lng,lat),13);
            var marker = new BMap.Marker(new BMap.Point(lng,lat));  // 创建标注
            markerTmp = marker;
            map.addOverlay(marker); //将标注添加到地图中
        }else{
            map.centerAndZoom("<{$area_baidu_map}>",13); //设置地图元素的可视层
        }

        map.addEventListener("touch", function(e) {
            e.preventDefault();
            alert("您点击了地图。");
            if (markerTmp != '') {
                map.removeOverlay(markerTmp);
            }
            lng = e.point.lng;
            document.getElementById("store_lnt").value = lng;
            lat = e.point.lat;
            document.getElementById("store_lat").value = lat;
            //在地图上面描点
            var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建标注
            markerTmp = marker;
            map.addOverlay(marker);
            var gc = new BMap.Geocoder();
            //获取地址的数据地址
            var pt = e.point;
            gc.getLocation(pt, function (rs) {
                var addComp = rs.addressComponents;
                address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
                document.getElementById("address_detail").value = address;
            });
        });

    </script>
